package com.zhihaoliang.animationtrain.transition

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.zhihaoliang.animationtrain.R
import com.zhihaoliang.animationtrain.databinding.MainItemBinding
import com.zhihaoliang.animationtrain.databinding.TransitionItemBinding
import kotlinx.android.synthetic.main.transition_item.view.*

/**
 * 创建日期：2020/3/27
 * 描述:Transiton 的Apater页面
 * 作者:支豪亮
 */
class TranstionAdapter(val list: MutableList<TransitionBean>, val callback: ITranstionCallback) :
    RecyclerView.Adapter<TranstionAdapter.TranstionViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TranstionViewHolder {
        val bing = TransitionItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return TranstionViewHolder(bing)
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: TranstionViewHolder, position: Int) {
        holder.bing.callback = callback
        holder.bing.transitionBean = list[position]
    }

    class TranstionViewHolder(val bing: TransitionItemBinding) : RecyclerView.ViewHolder(bing.root)
}